package action.order;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import service.OrderService;

public class OrderListAction {
	
	private OrderService orderService;
	private ArrayList<String> day, dateList;
	
	public OrderService getOrderService() {return orderService;}
	public void setOrderService(OrderService orderService) {this.orderService = orderService;}
	public ArrayList<String> getDateList() {return dateList;}
	public void setDateList(ArrayList<String> dateList) {this.dateList = dateList;}

	public String execute() {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session = request.getSession();
				
		String member_id = (String) session.getAttribute("member_id");
//		String member_id = "1003";
		
		if(member_id==null) {
			return "error";
		}
		day = orderService.selectOrderDayByMemberId(member_id);
		for(int i=0; i<day.size(); i++) {
			String date = day.get(i).substring(0, 14);
			System.out.println(date);
			dateList.add(date);
			System.out.println(dateList);
		}
		
		return "success";
	}
}